<template>
    <ContentWrap>
        <CardTitle title="RouterSearch 使用" />
        <code class="code-block mt-20px" >
            &lt;RouterSearch ref="routerSearchRef /&gt;<br/>
            &lt;e-button @click="handleRouterSearch"&gt;打开搜索&lt;/e-button&gt;<br/>
        </code>
        <CardTitle title="RouterSearch 代码示例" />
        <pre class="code-block">
            <code>
&lt;script setup lang="ts"&gt;
import { ref } from 'vue'

const handleRouterSearch = (keyword: string) => {
    console.log('路由搜索:', keyword)
    routerSearchRef.value.openSearch()
}
&lt;/script&gt;
            </code>
        </pre>
        <CardTitle title="RouterSearch 属性" />
        <p>无</p>
        
        
        <CardTitle title="RouterSearch 事件" />
        <table class="properties-table mt-20px">
            <thead>
                <tr>
                    <th>事件名</th>
                    <th>参数</th>
                    <th>说明</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>openSearch</td> 
                    <td>-</td>
                    <td>打开搜索菜单</td>
                </tr>
                
            </tbody>
        </table>
        
        <CardTitle title="RouterSearch 示例" />
       <div class="mt-20px">
            <div class="demo-section">
                <h4>基础用法</h4>
                <RouterSearch 
                    ref="routerSearchRef"
                />
                <p class="demo-result">点击按钮打开搜索菜单</p>
                <e-button @click="handleRouterSearch">打开搜索</e-button>   
            </div>
            
           
       </div>
    </ContentWrap>
</template>

<script setup lang="ts">
import {  ref } from 'vue'



// 演示搜索
const demoSearchKeyword = ref('')
const demoSearchResults = ref<any[]>([])
const selectedDemoRoute = ref('')

const routerSearchRef = ref()

const handleRouterSearch=()=>{
    routerSearchRef.value.openSearch()
}


</script>

<style lang="scss" scoped>
.demo-section {
    margin-bottom: 30px;
    padding: 20px;
    border: 1px solid #eee;
    border-radius: 6px;
    background: #fafafa;
    
    h4 {
        margin: 0 0 15px 0;
        color: #333;
        font-size: 16px;
    }
    
    h5 {
        margin: 15px 0 10px 0;
        color: #666;
        font-size: 14px;
        font-weight: 500;
    }
    
    .demo-result {
        margin: 10px 0 0 0;
        color: #666;
        font-size: 14px;
        font-family: monospace;
    }
}

.search-demo {
    .demo-input {
        width: 100%;
        padding: 10px 15px;
        border: 1px solid #ddd;
        border-radius: 6px;
        font-size: 14px;
        margin-bottom: 15px;
        
        &:focus {
            outline: none;
            border-color: #409EFF;
            box-shadow: 0 0 5px rgba(64, 158, 255, 0.3);
        }
    }
    
    .search-results {
        border: 1px solid #eee;
        border-radius: 6px;
        background: white;
        max-height: 300px;
        overflow-y: auto;
    }
    
    .result-item {
        padding: 12px 15px;
        border-bottom: 1px solid #f0f0f0;
        cursor: pointer;
        transition: background-color 0.3s;
        
        &:hover {
            background: #f8f9fa;
        }
        
        &:last-child {
            border-bottom: none;
        }
    }
    
    .route-info {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 5px;
        
        .route-title {
            font-weight: 500;
            color: #333;
        }
        
        .route-path {
            color: #666;
            font-size: 12px;
            font-family: monospace;
        }
    }
    
    .route-meta {
        .route-component {
            color: #999;
            font-size: 12px;
        }
    }
    
    .no-results {
        padding: 20px;
        text-align: center;
        color: #999;
        font-style: italic;
    }
}

.route-info-display {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    
    .info-card {
        border: 1px solid #eee;
        border-radius: 8px;
        background: white;
        overflow: hidden;
        transition: box-shadow 0.3s;
        
        &:hover {
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        }
    }
    
    .card-header {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 15px;
        background: #f8f9fa;
        border-bottom: 1px solid #eee;
        
        .route-title {
            font-weight: 500;
            color: #333;
        }
    }
    
    .card-body {
        padding: 15px;
        
        p {
            margin: 8px 0;
            font-size: 14px;
            color: #666;
            
            strong {
                color: #333;
            }
        }
    }
}
</style> 